package com.mygdx.game.group;

import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.mygdx.game.MainGame;
import com.mygdx.game.group.basegroup.BaseGroup;
import com.mygdx.game.resource.Res;

public class TopGroup extends BaseGroup {
    private Image gameLogo;

    private ScoreGroup currentScore;
    private ScoreGroup bestScore;


    public TopGroup(MainGame mainGame) {
        super(mainGame);
        init();
    }

    public void init() {
        gameLogo = new Image(getMainGame().getTextureAtlas().findRegion(Res.Atlas.GAME_LOGO));
        gameLogo.setPosition(5, 5);
        addActor(gameLogo);
        //以世界宽度为宽，logo高度为高
        setSize(getMainGame().getWorldWidth() - 10, gameLogo.getHeight());

        currentScore = new ScoreGroup(getMainGame(), getMainGame().getTextureAtlas().findRegion(Res.Atlas.GAME_SCORE_BG_NOW));
        currentScore.setX(186);
        currentScore.setY(getHeight() - currentScore.getHeight());
        //currentScore.setPosition(185,getHeight()-currentScore.getHeight());
        addActor(currentScore);

        bestScore = new ScoreGroup(getMainGame(), getMainGame().getTextureAtlas().findRegion(Res.Atlas.GAME_SCORE_BG_BEST));
        bestScore.setPosition(320, getHeight() - bestScore.getHeight());
        addActor(bestScore);

    }

    public void reStart(){
        currentScore.setScore(0);
    }

    //获取当前分数
    public void addCurrentScore(int score){
        currentScore.addScore(score);
        if (currentScore.getScore() > bestScore.getScore()){
            setBestScore(currentScore.getScore());
        }
    }

    public int getCurrentScore(){
        return currentScore.getScore();
    }

    public void setBestScore(int score){
        bestScore.setScore(score);
    }

    public int getBestScore(){
        return bestScore.getScore();
    }
}
